Skip to content

feat: vendor native DeepSeek Web XML tool-call normalizer#25

Open
RC-ia wants to merge 2 commits into
ForgetMeAI:mainfrom
RC-ia:feat/native-toolcall-normalizer
Open

feat: vendor native DeepSeek Web XML tool-call normalizer#25
RC-ia wants to merge 2 commits into
ForgetMeAI:mainfrom
RC-ia:feat/native-toolcall-normalizer

Conversation

@RC-ia

@RC-ia RC-ia commented Jul 13, 2026

Copy link
Copy Markdown

Summary

DeepSeek Web emits native function calls as XML:

<tool_call name="todo_write">
[{"id":"1","content":"...","status":"in_progress"}]
</tool_call>

The current parseToolCall() expected a JSON body inside the tag and silently dropped these as plain text. This PR vendors a deterministic normalizer (toolcall_normalizer.js) that runs as a FAST-PATH inside parseToolCall() and converts the native shape (plus strict-JSON / fenced-JSON / legacy TOOL_CALL: variants) into a clean OpenAI tool_calls payload.

  • Zero new npm dependencies (Node 18+, same as the project).
  • The normalizer is a drop-in companion of RC-ia/deepseek-toolcall-normalizer.
  • Behavior for all existing formats is preserved; the fast-path only short-circuits when the normalizer actually recognizes a tool call.

Changes

  • toolcall_normalizer.js — new, deterministic multi-shape parser.
  • server.js — require the normalizer (guarded try/catch) + pre-pass in parseToolCall(); export parseToolCall for tests.
  • tests/unit.test.js — +3 tests (native XML, plain-text returns null, multi-parameter mixed types).
  • README.md — adds a short Tool-call normalization patch section crediting the upstream project.

Test plan

npm test
All 12 unit tests pass (9 original + 3 new). Sample log line on a native call:
[parseToolCall] SUCCESS normalized (native/companion): todo_write

Notes

  • Credits to ForgetMeAI (t.me/forgetmeai) for the upstream proxy — MIT.
  • Happy to adjust (inline vs separate file, code style) if you prefer.

Generated with Hermes Agent (https://hermes-agent.nousresearch.com)

RC-ia added 2 commits July 12, 2026 22:48
…seToolCall gap)

DeepSeek Web emits native function calls as XML:
  <tool_call name="x"><parameter name="p">...</parameter></tool_call>
The original parseToolCall() expected a JSON body and dropped these as plain text.

Adds toolcall_normalizer.js as a FAST-PATH inside parseToolCall() that parses the
native shape (plus strict/fenced JSON and legacy TOOL_CALL:) into clean OpenAI
tool_calls. Zero new npm deps.

- toolcall_normalizer.js: deterministic multi-shape parser (companion of
  RC-ia/deepseek-toolcall-normalizer)
- server.js: require normalizer + pre-pass in parseToolCall(); export parseToolCall
- tests/unit.test.js: +3 tests (native XML, plain text null, multi-param)
- README:adds a Tool-call normalization patch section (credits ForgetMeAI upstream
  + companion normalizer)

All 12 unit tests pass (9 original + 3 new). Credits to ForgetMeAI (t.me/forgetmeai).
…l-normalizer

# Conflicts:
#	tests/unit.test.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant